#pragma once
#include"GRiComponent.h"

class GRiCmpTransform:public GRiComponent
{
public:
	GRiCmpTransform(GUSPtr<GRiObj> obj) :
		GRiComponent(obj) {}
	GRiCmpTransform() = default;
	
	GMath::Vector3 GetLocation()const
	{
		return Location;
	}

	GMath::Vector3 GetRotation()const
	{
		return Rotation;
	}

	GMath::Vector3 GetScale()const
	{
		return Scale;
	}
	void SetLocation(float x, float y, float z)
	{
		Location[0] = x;
		Location[1] = y;
		Location[2] = z;
		bTransformClean = false;
	}

	void SetRotation(float pitch, float yaw, float roll)
	{
		Rotation[0] = pitch;
		Rotation[1] = yaw;
		Rotation[2] = roll;
		bTransformClean = false;
	}

	void SetScale(float x, float y, float z)
	{
		Scale[0] = x;
		Scale[1] = y;
		Scale[2] = z;
		bTransformClean = false;
	}

	GMath::Matrix GetWorldMat() {
		if (bTransformClean = !bTransformClean)
		{
			mWorld = GMath::Matrix::TRS(Location, Rotation, Scale);
		}
		return mWorld;
	};

protected:

private:
	GMath::Vector3 Location = { 0.0f, 0.0f, 0.0f };
	GMath::Vector3 Rotation = { 0.0f, 0.0f, 0.0f };
	GMath::Vector3 Scale = { 1.0f, 1.0f, 1.0f };
	GMath::Matrix mWorld;
private:
	bool bTransformClean;
};

